package com.angel.web.app;

import java.util.List;
import java.util.Map;

import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Controller;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.ResponseBody;

import com.angel.core.base.JsonEntity;
import com.angel.core.util.JsonUtil;
import com.angel.health.BuzAttention;
import com.angel.provider.app.AppBuzAttentionProvider;

/** 
* @author 作者姓名  cheng
* @version 
* 创建时间：2016年9月14日上午11:40:51
* 类说明  关注
*/
@Controller
@RequestMapping("app/attention")
public class AppAttentionController {

	@Autowired
	private AppBuzAttentionProvider provider;

	@ResponseBody
	@RequestMapping(value = "index", produces = "application/json; charset=utf-8")
	public String index(BuzAttention attention) {
		List<Map<String, Object>> list = provider.findAll(attention);
		return JsonUtil.toJson(new JsonEntity("200",list));
	}

	@ResponseBody
	@RequestMapping(value = "insert", produces = "application/json; charset=utf-8")
	public String insert(BuzAttention attention) {
		int i = provider.insert(attention);
		if(i>0){
			return JsonUtil.toJson(new JsonEntity("200", "新增成功！"));
		}
		return JsonUtil.toJson(new JsonEntity("-1", "新增失败！"));
	}

	@ResponseBody
	@RequestMapping(value = "delete", produces = "application/json; charset=utf-8")
	public String delete(BuzAttention attention) {
		int i = provider.delByAttention(attention);
		if(i>0){
			return JsonUtil.toJson(new JsonEntity("200", "取消成功！"));
		}
		return JsonUtil.toJson(new JsonEntity("-1", "取消失败！"));
	}
}
